package com.example.demo.mapper;

import com.example.demo.model.entity.Prize;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ActivityPrizeMapper {

    @Insert("insert into activity_prize (activity_id, level, number, type, probability, goods_id, coupon_id, remaining) " +
            "values(#{activityId}, #{level}, #{number}, #{type}, #{probability}, #{goodsId}, #{couponId}, #{remaining})")
    int insert(Prize prize);

    @Select("select * from activity_prize where activity_id = #{activityId}")
    List<Prize> selectByActivityId(int activityId);

    @Delete("delete from activity_prize where activity_id = #{activityId}")
    void deleteActivity(int activityId);

    @Update("update activity_prize set number = #{number}, type = #{type}, goods_id =#{goodsId}," +
            " coupon_id =#{couponId}, remaining = #{remaining} where activity_id = #{activityId} and level = #{level}")
    void update(Prize prize);
}
